package org.dant.ant.extension.net.rmi;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

import org.dant.ant.extension.net.DefaultDispatcher;
import org.dant.ant.extension.net.Dispatcher;
import org.dant.ant.extension.tasks.internal.RemoteCommand;
import org.dant.ant.extension.tasks.internal.RemoteResponse;

public class DistributedAntImpl extends UnicastRemoteObject implements DistributedAnt {

    protected Dispatcher dispatcher = new DefaultDispatcher();
    private String fullURL;

    public DistributedAntImpl() throws RemoteException {
        super();
    }

    public void setDispatcher(Dispatcher d) {
        this.dispatcher = d;
    }

    public void setFullURL(String u) {
        this.fullURL = u;
    }

    public RemoteResponse remoteCall(RemoteCommand rCmd) throws RemoteException {
        RemoteResponse response = new RemoteResponse();
        response.setFullURL(fullURL);
        dispatcher.dispatch(rCmd, response);
        return response;
    }

}

